<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Inscription extends Application_Model_ModelAbstract
{

    /**
     * Database var type bigint(20)
     *
     * @var int
     */
    protected $_Idinscription;

    /**
     * Database var type tinyint(4)
     *
     * @var int
     */
    protected $_Validation;

    /**
     * Database var type varchar(8)
     *
     * @var string
     */
    protected $_ParticipantCin;

    /**
     * Database var type int(4)
     *
     * @var int
     */
    protected $_SessionIdSession;


    /**
     * Parent relation fk_inscription_participant1
     *
     * @var Application_Model_Participant
     */
    protected $_Participant;

    /**
     * Parent relation fk_inscription_session1
     *
     * @var Application_Model_Session
     */
    protected $_Session;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idinscription'=>'Idinscription',
            'validation'=>'Validation',
            'participant_cin'=>'ParticipantCin',
            'session_id_session'=>'SessionIdSession',
        ));

        $this->setParentList(array(
            'FkInscriptionParticipant1'=> array(
                    'property' => 'Participant',
                    'table_name' => 'Participant',
                ),
            'FkInscriptionSession1'=> array(
                    'property' => 'Session',
                    'table_name' => 'Session',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column idinscription
     *
     * @param int $data
     * @return Application_Model_Inscription
     */
    public function setIdinscription($data)
    {
        $this->_Idinscription = $data;
        return $this;
    }

    /**
     * Gets column idinscription
     *
     * @return int
     */
    public function getIdinscription()
    {
        return $this->_Idinscription;
    }

    /**
     * Sets column validation
     *
     * @param int $data
     * @return Application_Model_Inscription
     */
    public function setValidation($data)
    {
        $this->_Validation = $data;
        return $this;
    }

    /**
     * Gets column validation
     *
     * @return int
     */
    public function getValidation()
    {
        return $this->_Validation;
    }

    /**
     * Sets column participant_cin
     *
     * @param string $data
     * @return Application_Model_Inscription
     */
    public function setParticipantCin($data)
    {
        $this->_ParticipantCin = $data;
        return $this;
    }

    /**
     * Gets column participant_cin
     *
     * @return string
     */
    public function getParticipantCin()
    {
        return $this->_ParticipantCin;
    }

    /**
     * Sets column session_id_session
     *
     * @param int $data
     * @return Application_Model_Inscription
     */
    public function setSessionIdSession($data)
    {
        $this->_SessionIdSession = $data;
        return $this;
    }

    /**
     * Gets column session_id_session
     *
     * @return int
     */
    public function getSessionIdSession()
    {
        return $this->_SessionIdSession;
    }

    /**
     * Sets parent relation ParticipantCin
     *
     * @param Application_Model_Participant $data
     * @return Application_Model_Inscription
     */
    public function setParticipant(Application_Model_Participant $data)
    {
        $this->_Participant = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['cin'];
        }

        $this->setParticipantCin($primary_key);

        return $this;
    }

    /**
     * Gets parent ParticipantCin
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Participant
     */
    public function getParticipant($load = true)
    {
        if ($this->_Participant === null && $load) {
            $this->getMapper()->loadRelated('FkInscriptionParticipant1', $this);
        }

        return $this->_Participant;
    }

    /**
     * Sets parent relation SessionIdSession
     *
     * @param Application_Model_Session $data
     * @return Application_Model_Inscription
     */
    public function setSession(Application_Model_Session $data)
    {
        $this->_Session = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['id_session'];
        }

        $this->setSessionIdSession($primary_key);

        return $this;
    }

    /**
     * Gets parent SessionIdSession
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Session
     */
    public function getSession($load = true)
    {
        if ($this->_Session === null && $load) {
            $this->getMapper()->loadRelated('FkInscriptionSession1', $this);
        }

        return $this->_Session;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Inscription
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Inscription());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Inscription::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdinscription() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idinscription = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdinscription()));
    }
}
